home *** CD-ROM | disk | FTP | other *** search
/ LineOne ISP Sign-Up 5 / LineOne.iso / assets / cxt / scripts / parentScripts.cst / 00041_buddyAPIxtra parent.ls < prev    next >
Encoding:
Text File  |  2001-01-27  |  7.1 KB  |  228 lines

  1. -- 2000.03.08
  2. -- Clive Green <clivegreen@atlas.co.uk>
  3.  
  4. ------------------------------------------------------------------------------------------------------
  5.  
  6. -- taps into features of the Buddy API Xtra:
  7.  
  8. ------------------------------------------------------------------------------------------------------
  9.  
  10. -- declare properties:
  11. property main     -- main code directory object
  12. property xtraName -- starting string of the name under which the buddyAPI xtra is known
  13.  
  14. ------------------------------------------------------------------------------------------------------
  15.  
  16. on new me,L
  17.   
  18.   -- (1) extract and check arguments:
  19.   
  20.   -- check for a parameter list:
  21.   if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"buddyAPIxtra:new"]
  22.   
  23.   -- a reference to the parent codebase is REQUIRED:
  24.   main = L[#main]
  25.   if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"buddyAPIxtra:new"]
  26.   
  27.   --------------------
  28.   
  29.   -- (2) make platform-specific preparations:
  30.   um = main.getUtilityMethods()
  31.   p  = um.thePlatform()
  32.   
  33.   if (p = #PC) then
  34.     
  35.     -- for Windows ONLY, we need a userName and registration number in order to initialise
  36.     -- this xtra for use:
  37.     
  38.     -- get the data manager:
  39.     dm = main.getDataManager()
  40.     if (ilk(dm) <> #instance) then return dm
  41.     
  42.     -- obtain data set:
  43.     d = dm.getData([#set:#settings, #item:#buddyRegData])
  44.     if stringP(d[#error]) then return d   
  45.     a = d[#name]
  46.     b = d[#code]
  47.     
  48.     -- we need a string and an integer to proceed:
  49.     if not stringP(a) or not integerP(b) then return ┬¼
  50.     [#error:#badRegDataSupplied, #msg:"buddyAPIxtra:new"]
  51.     
  52.     -- attempt to register the Buddy xtra prior to use:
  53.     n = baRegister(a,b)
  54.     if not(n) then return [#error:#registrationFailed, #msg:"buddyAPIxtra:new"]
  55.     
  56.   end if
  57.   
  58.   --------------------
  59.   
  60.   -- pass back validated manager object to the caller:
  61.   return me
  62.   
  63.   ----------------------------------------------------------------------------------------------------
  64.   
  65. on driveIsCDROM me,n
  66.   
  67.   -- indicate whether the drive letter supplied is a CD-ROM drive:
  68.   return (baDiskInfo(n,"type") = "CD-ROM")
  69.   
  70.   ----------------------------------------------------------------------------------------------------
  71.   
  72. on fileExists me,f
  73.   
  74.   -- check argument is a populated string:
  75.   if not stringP(f) then return ┬¼
  76.   [#error:#noFilePathSupplied, #msg:"buddyAPIxtra:fileExists"]
  77.   
  78.   if not length(f) then return ┬¼
  79.   [#error:#emptyFilePathSupplied, #msg:"buddyAPIxtra:fileExists"]
  80.   
  81.   --------------------
  82.   
  83.   -- pass back the filePath if it actually points to a existing file:
  84.   if baFileExists(f) then return f
  85.   
  86.   -- flag failure:
  87.   return [#error:#fileNotFound, #msg:"buddyAPIxtra:fileExists" && f]
  88.   
  89.   ----------------------------------------------------------------------------------------------------
  90.   
  91. on launchFile me,L
  92.   
  93.   -- we need a parameter listing:
  94.   if ilk(L) <> #propList then return ┬¼
  95.   [#error:#noParamListSupplied, #msg:"buddyAPIxtra:launchCDfile"]
  96.   
  97.   -- extract the filePath supplied: 
  98.   f = L[#filePath]
  99.   
  100.   if not stringP(f) then return ┬¼
  101.   [#error:#badFilePathSupplied, #msg:"buddyAPIxtra:launchCDfile"]
  102.   
  103.   --------------------
  104.   
  105.   -- check file f's existence:
  106.   f = me.fileExists(f) 
  107.   if not stringP(f) then return f
  108.   
  109.   -- in what manner should the file f be opened?
  110.   s = L[#state]
  111.   if not stringP(s) then s = "Normal"
  112.   
  113.   --------------------
  114.   
  115.   -- if the file n exists, attempt to open it in the state (s):
  116.   r = baOpenFile(f,s)
  117.   
  118.   -- a buddyAPI integer result of less than 32 indicates an error:
  119.   if r < 32 then return ┬¼
  120.   [#error:#fileOpenFailure, #msg:"buddyAPIxtra:launchCDfile - budAPI error code:" && r]
  121.   
  122.   -- flag success to the caller:
  123.   return 1
  124.   
  125.   ----------------------------------------------------------------------------------------------------
  126.   
  127. on getRegistryString me,L
  128.   
  129.   -- This obtains a string value from the windows registry. Note that the error flag (#null) is
  130.   -- returned if the requested value does not exist, or isn't a string.
  131.   
  132.   -- this function is implemented for Windows only:
  133.   um = main.getUtilityMethods()
  134.   p  = um.thePlatform()
  135.   
  136.   if (p <> #PC) then return ┬¼
  137.   [#error:#windowsOnlyMethod, #msg:"buddyAPIxtra:getRegistryString"]
  138.   
  139.   --------------------
  140.   
  141.   -- we need a parameter listing:
  142.   if ilk(L) <> #propList then return ┬¼
  143.   [#error:#noParamListSupplied, #msg:"buddyAPIxtra:getRegistryString"]
  144.   
  145.   -- extract and (cursorily) check items supplied:
  146.   br = L[#branch]
  147.   if not stringP(br) then return [#error:#badBranchParam, #msg:"buddyAPIxtra:getRegistryString"]
  148.   
  149.   kn = L[#keyName]
  150.   if not stringP(kn) then return [#error:#badKeynameParam, #msg:"buddyAPIxtra:getRegistryString"]
  151.   
  152.   vn = L[#valueName]
  153.   if not stringP(vn) then return [#error:#badValuenameParam, #msg:"buddyAPIxtra:getRegistryString"]
  154.   
  155.   --------------------
  156.   
  157.   -- what string returned represents an error?
  158.   em = "#null"
  159.   
  160.   -- attempt to extract the registry string value:
  161.   s = baReadRegString(kn,vn,em,br)
  162.   
  163.   -- pass back the result:
  164.   if s = em then return [#error:#readRegStringFailure, #msg:"buddyAPIxtra:getRegistryString"]
  165.   return s
  166.   
  167.   ----------------------------------------------------------------------------------------------------
  168.   
  169. on getRegistryValueNames me,L
  170.   
  171.   -- This returns a LINGO linear list containing all the value names listed at a particular windows
  172.   -- registry location. The error flag (#null) is returned if the specified location EITHER does not
  173.   -- exist, or is empty (- the BuddyAPI doesn't seem to care which).
  174.   
  175.   --------------------
  176.   
  177.   -- this function is implemented for Windows only:
  178.   um = main.getUtilityMethods()
  179.   p  = um.thePlatform()
  180.   
  181.   if (p <> #PC) then return ┬¼
  182.   [#error:#windowsOnlyMethod, #msg:"buddyAPIxtra:getRegistryValueNames"]
  183.   
  184.   --------------------
  185.   
  186.   -- we need a parameter listing:
  187.   if ilk(L) <> #propList then return ┬¼
  188.   [#error:#noParamListSupplied, #msg:"buddyAPIxtra:getRegistryValueNames"]
  189.   
  190.   -- extract and (cursorily) check items supplied:
  191.   br = L[#branch]
  192.   if not stringP(br) then return [#error:#badBranchParam, #msg:"buddyAPIxtra:getRegistryValueNames"]
  193.   
  194.   kn = L[#keyName]
  195.   if not stringP(kn) then return [#error:#badKeynameParam, #msg:"buddyAPIxtra:getRegistryValueNames"]
  196.   
  197.   --------------------
  198.   
  199.   -- pass a  LINGO linear list back to the caller:
  200.   return baRegValueList(kn,br)
  201.   
  202.   ----------------------------------------------------------------------------------------------------
  203.   
  204. on bkgndStage me
  205.   
  206.   -- the baWindowToBack() function doesn't work on the mac:
  207.   um = main.getUtilityMethods()
  208.   p  = um.thePlatform()
  209.   if (p <> #PC) then return 1
  210.   
  211.   -- send the projector layer to the back:
  212.   return baWindowToBack(baWinHandle())
  213.   
  214.   ----------------------------------------------------------------------------------------------------
  215.   
  216. on hideStage me
  217.   
  218.   -- minimise the parent window:
  219.   return baSetWindowState(baWinHandle(),"Minimised")
  220.   
  221.   ----------------------------------------------------------------------------------------------------
  222.   
  223. on getOSname me
  224.   
  225.   -- what is the current operating system name?
  226.   return baVersion("os")
  227.   
  228.   ----------------------------------------------------------------------------------------------------